/**
 * 
 */
package com.demo2do.strawberry.entity.startup.detail;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.demo2do.strawberry.entity.startup.Startup;

/**
 * @author lute
 *
 */
@Entity
@Table(name = "startup_resource")
public class Resource {
	
	@Id
	@GeneratedValue
	private Long id;
	
	@Column(length = 511)
	private String url;
	
	@Enumerated(EnumType.ORDINAL)
	private ResourceType type;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	private Startup startup;
	
	/**
	 * default constructor
	 */
	public Resource() {
		
	}
	
	/**
	 * @param startup
	 * @param name
	 */
	public Resource(String url, ResourceType type, Startup startup) {
		this.url = url;
		this.type = type;
		this.startup = startup;
	}
	
	/**
	 * @return determine whether the resource is video
	 */
	public boolean isVideo() {
		return this.type.equals(ResourceType.VIDEO);
	}
	
	/**
	 * @return determine whether the resource is picture
	 */
	public boolean isPicure() {
		return this.type.equals(ResourceType.PICTURE);
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}
	
	/**
	 * @return the type
	 */
	public ResourceType getType() {
		return type;
	}

	/**
	 * @return the startup
	 */
	public Startup getStartup() {
		return startup;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @param url the url to set
	 */
	public void setUrl(String url) {
		this.url = url;
	}
	
	/**
	 * @param type the type to set
	 */
	public void setType(ResourceType type) {
		this.type = type;
	}

	/**
	 * @param startup the startup to set
	 */
	public void setStartup(Startup startup) {
		this.startup = startup;
	}

}
